//Source file: D:\\WTK104\\apps\\Toddtris\\src\\com\\toddsoft\\toddtris\\midlet\\CustomKeyHandler.java

package com.toddsoft.toddtris.midlet;


class CustomKeyHandler extends KeyHandler {
    private final int leftKey;
    private final int rightKey;
    private final int clockwiseKey;
    private final int anticlockwiseKey;
    private final int downKey;
    private final int dropKey;
    
    /**
     * @param ia
     */
    CustomKeyHandler(int[] ia) {
        int i = 0;
        this.leftKey = ia[i++];
        this.rightKey = ia[i++];
        this.clockwiseKey = ia[i++];
        this.anticlockwiseKey = ia[i++];
        this.downKey = ia[i++];
        this.dropKey = ia[i++];     
    }
    
    /**
     * @param keyCode
     * @return int
     */
    public int translateKeyCode(int keyCode) {
        if (keyCode == leftKey) {
            return LEFT;
        } else if (keyCode == rightKey) {
            return RIGHT;
        } else if (keyCode == clockwiseKey) {
            return CLOCKWISE;
        } else if (keyCode == anticlockwiseKey) {
            return ANTICLOCKWISE;
        } else if (keyCode == downKey) {
            return DOWN;
        } else if (keyCode == dropKey) {
            return DROP;
        } else {
            return -1;
        }     
    }
}
